package kassiopeia.agent.seda.event;

import kassiopeia.plugin.Event;
import org.apache.log4j.Logger;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

public class EventQueue extends LinkedBlockingQueue<Event> {

    private final Logger log = Logger.getLogger(EventQueue.class);

    public EventQueue() {
        super();
    }

    public void putEvent(Event event) {
        try {
            if (!this.offer(event, 1L, TimeUnit.SECONDS)) {
                log.warn("Cannot add event to queue (queue is full)");
            }
        } catch (InterruptedException ix) {
            log.error("Cannot add event to queue (error occurred)", ix);
        }
    }
}
